package org.jeecg.jt808.operate;


import org.jeecg.jt808.JTT808Encoder;
import org.jeecg.jt808.JTT808Message;
import org.jeecg.jt808.Jt808Control.Jt808CentralControlConfig;
import org.jeecg.jt808.modbus.ModbusParams;
import org.jeecg.jt808.processor.MessageType;
import org.jeecg.jt808.vo.Packet;
import org.springframework.stereotype.Component;

import static org.jeecg.jt808.util.JT808Util.bytesToHexString;



public class RemoteControlPairMessageGenerator extends TerminalControlMessageGenerator {

    @Override
    public String generateMessage(JTT808Message message) {
        message.id = 0x8105; // 终端控制消息 ID
        message.packetCount = 0;
        message.packetIndex = 0;

        Packet p = Packet.create(1);
        p.addByte((byte) 0xB0); // 命令字: 遥控器配对 (0xB0)

        message.body = p.getBytes();
        return bytesToHexString(JTT808Encoder.encode(message)); //  保持接口一致性，此处无需处理
    }

    @Override
    public String generateMessage(JTT808Message message, ModbusParams params) {
        return ""; // 保持接口一致性，此处无需处理
    }

    @Override
    public String generateMessage(JTT808Message message, Jt808CentralControlConfig config) {
        message.id = 0x8105; // 终端控制消息 ID
        message.packetCount = 0;
        message.packetIndex = 0;

        Packet p = Packet.create(1);
        p.addByte((byte) 0xB0); // 命令字: 遥控器配对 (0xB0)

        message.body = p.getBytes();
        return bytesToHexString(JTT808Encoder.encode(message));
    }


    @Override
    public String getType() {
        return MessageType.REMOTE_CONTROL_PAIR.name(); // 定义新的消息类型
    }
}